Sversyl Git
rnalias - Manage aliases
Watchout! This is still WIP!
Installation
$ . <location of virtual env>/bin/acvtivate
$ git clone rns://d0841b1d8eff85c4388bf0e12dd7097d/reticulum/rnalias
$ cd rnalias
Test
$ python -m unittest discover --start-directory tests/
Test CLI
$ sh tests/test.sh > tests/test.out && diff tests/test.out tests/test.expected
Build, install
$ python -m build
$ pip install dist/rnalias-<INSERT VERSION>-py3-none-any.whl
Install editable
$ pip install --editable .
Usage
With and around Reticulum, naturally there are a lot of hashes in use. _rnalias_ can help a human managing them.
$ rnalias --help
usage: rnalias [-h] {set,get,all,exists,delete,clear} ...
positional arguments:
{set,get,all,exists,delete,clear}
commands
set create alias
get fetch an alias
all fetch all aliases
exists test if an alias exists
delete delete an alias
clear clear out alias database
options:
-h, --help show this help message and exit
-v, --version print version and exit
All subcommands will also accept -h|--help
Resolve aliases
An aliases value may itself be another alias. Use -r|--resolve to lookup it up.
This is a simple mechanism to create groups:
The following lines create an alias _developers_ pointing to more aliases _tom_ and _jerry_:
$ rnalias set tom nevoh8caoshiejiaz9shah4uaHeSeesh
$ rnalias set jerry eipevae7reihahhoow9Eo6iewahchoh8
$ rnalias set --resolve developers tom,jerry
$ rnalias get developers
$ rnalias get --resolve developers
set -r|--resolve ... will try to resolve the given value, and fail if it can't.
get -r|--resolve ... will try to resolve the given name, but take it as-is if it can't.
Force
Existing aliases can be set (overwritten) with -f|--force.
Separator
Values in lists are delimited by default with ",". Use -s|--separator to change it.
Env vars
The following env vars are recognised: RNALIAS_FORCE, RNALIAS_RESOLVE, RNALIAS_SEPARATOR, RNALIAS_DB_FILE
Commandline options have precedence. The order is: (hardcoded) default, env var, commandline
Booleans (RNALIAS_FORCE, RNALIAS_RESOLVE) are turned _on_ with one out of ('y', 'yes', 't', 'true', 'on', '1') and turned _off_ with one out of ('n', 'no', 'f', 'false', 'off', '0'):
See --help for the various subcommands get and set for details of those options.
Demos
rnpath
See demo/rnpath.py.diff for a simple demonstration: Patching rnpath to lookup aliases (when -l|--lookup is given):
$ rnalias set tom nevoh8caoshiejiaz9shah4uaHeSeesh
$ rnpath --lookup tom
Served by rngit 1.4.0 - Generated in 0.03s